package cn.tedu.csmall.product.controller;

import cn.tedu.csmall.product.pojo.dto.AlbumAddNewDTO;
import cn.tedu.csmall.product.pojo.dto.Attribute_templateAddNewDTO;
import cn.tedu.csmall.product.pojo.entity.AttributeTemplate;
import cn.tedu.csmall.product.service.IAlbumService;
import cn.tedu.csmall.product.service.IAttribute_templateService;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Slf4j
@Api(tags = "02属性模板管理模块")
@RestController
public class Attribute_templateController {
    @Autowired
    IAttribute_templateService attribute_templateService;
    @ApiOperation("添加属性模板")
    @ApiOperationSupport(order = 100)
    @PostMapping("/attribute_template/add-new")
    public String addNew(Attribute_templateAddNewDTO attributeTemplateAddNewDTO){
        try {
            attribute_templateService.addNew(attributeTemplateAddNewDTO);
            return "添加属性模板成功！";
        } catch (Exception e) {
            return "添加属性模板失败，尝试添加的属性模板名称已经被占用";
        }
    }
    @ApiOperation("删除属性模板")
    @ApiOperationSupport(order = 200)
    @PostMapping("/delete")
    public String delete(Long id){
        log.debug("开始处理【删除相册】的请求，参数：{}", id);
        attribute_templateService.delete(id);
        return "ok";
    }
}
